﻿/**
 * @usage	位图文本
 */
package org.nickro.utils
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.text.TextField;
	
	public class BitmapTextField extends Bitmap
	{
		public function BitmapTextField(text:TextField)
		{
			if(text == null) throw new Error("Unabled to draw null TextField");
			if(text.text == "" || text.text == null) throw new Error(text.toString() + ".text isn't null");
			createBitmapText(text);
		}
		
		private function createBitmapText(text:TextField):void
		{
			var bd:BitmapData = new BitmapData(text.width + 4,text.height + 2,true,null);
			bd.draw(text);
			this.bitmapData = bd;
			this.smoothing = true;
			this.pixelSnapping = "always";
		}
	}
}